home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / xtrap_p.zip / Xtrap_p
Text File  |  1993-01-27  |  5KB  |  149 lines

  1. The following patches to the X11R5 sample server allow an X client to
  2. emulate a user interacting with a window manager, or other interaction
  3. which may trigger another client to issue an X_GrabServer request.  These
  4. patches should be applied to an X11R5 sample server that is already set up
  5. to use the DEC-XTrap extension, either version 3.2 (came out with X11R5)
  6. or version 3.3 (recently came out).  DEC-XTrap is an extension to X which
  7. facilitates user emulation.
  8.  
  9. The grab server problem has been previously worked around (as of version 3.2
  10. of XTrap) by disabling server grabs entirely.  Before these patches, I have
  11. not been able to work around the grab server problem in an elegant and
  12. publicly available fashion.
  13.  
  14. With these patches, server grabs behave normally for all clients other than
  15. XTrap controlling clients, yet XTrap controlling clients are not locked out
  16. from making input simulation requests of the X server when another client
  17. issues a grab.
  18.  
  19. These patches override the XTrap behavior of disabling grabs entirely
  20. with a less-intrusive solution - server grab behavior is not totally disabled,
  21. just slightly less restrictive.
  22.  
  23. In this fashion, XTrap may still be used in a testing environment where
  24. it may be important to preserve the behavior of clients during server grabs.
  25. Or simply it may be important to emulate a user moving an xclock window
  26. around without getting stray bits as the second hand is updated. (the window
  27. manager grabs the server during a window move operation so that an atomic
  28. copyarea operation may be performed, but with server grabs entirely
  29. disabled, an xclock may update its window at the same instant a rubberband
  30. is drawn through a clock hand, producing unexpected results)
  31.  
  32. This modified behavior will only be have an effect if an XTrap controlling
  33. client which selects to the special XTrap behavior of disabling server grabs,
  34. and it, or another XTrap controlling client, issues an X request while
  35. another X client has grabbed the X server.
  36.  
  37. These patches include 2 new routines to be added into server/os/connection.c,
  38. calls to those 2 routines in extensions/server/xtrap/xtrapdi.c, and removing
  39. (by ifdef) 2 lines from server/dix/dispatch.c.
  40.  
  41. These changes are short enough that I'm posting them to comp.windows.x.
  42. Please feel free to redistribute them as widely and freely as any
  43. contributed X software.
  44.  
  45. --Robert Chesler                rob@chesler.nashua.nh.us
  46.  
  47. *** server/os/connection.c.last    Mon Aug 24 14:01:17 1992
  48. --- server/os/connection.c    Tue Oct 13 23:34:59 1992
  49. ***************
  50. *** 852,857 ****
  51. --- 852,890 ----
  52.       BITCLEAR(AllSockets, fd);
  53.   }
  54.   
  55. + /* for new version of XTrap */
  56. + void
  57. + AlsoListenToClient(client)
  58. +     ClientPtr client;
  59. + {
  60. +     if (client && GrabInProgress && (GrabInProgress != client->index))
  61. +     {
  62. +     OsCommPtr oc = (OsCommPtr)client->osPrivate;
  63. +     int connection = oc->fd;
  64. +     BITSET(AllClients, connection);
  65. +     BITSET(AllSockets, connection);
  66. +     BITSET(LastSelectMask, connection);
  67. +     if (GETBIT(SavedClientsWithInput, connection))
  68. +         BITSET(ClientsWithInput, connection);
  69. +     }
  70. + }
  71. + /* for new version of XTrap */
  72. + void
  73. + AlsoUnListenToClient(client)
  74. +     ClientPtr client;
  75. + {
  76. +     if (client && GrabInProgress && (GrabInProgress != client->index))
  77. +     {
  78. +     OsCommPtr oc = (OsCommPtr)client->osPrivate;
  79. +     int connection = oc->fd;
  80. +     BITCLEAR(AllClients, connection);
  81. +     BITCLEAR(AllSockets, connection);
  82. +     BITCLEAR(LastSelectMask, connection);
  83. +     BITCLEAR(ClientsWithInput, connection);
  84. +     }
  85. + }
  86.   /*****************
  87.    * OnlyListenToOneClient:
  88.    *    Only accept requests from  one client.  Continue to handle new
  89. *** server/dix/dispatch.c.last    Tue Oct 13 23:44:13 1992
  90. --- server/dix/dispatch.c    Fri Nov 15 22:47:17 1991
  91. ***************
  92. *** 221,229 ****
  93. --- 221,231 ----
  94.           /* KillClient can cause this to happen */
  95.           continue;
  96.           }
  97. + #ifndef XTRAP    /* new XTRAP */
  98.           /* GrabServer activation can cause this to be true */
  99.           if (grabbingClient && (client != onlyClient))
  100.           break;
  101. + #endif /* new XTRAP */
  102.           isItTimeToYield = FALSE;
  103.    
  104.               requestingClient = client;
  105. *** extensions/server/xtrap/xtrapdi.c.last    Mon Sep 14 16:44:02 1992
  106. --- extensions/server/xtrap/xtrapdi.c    Tue Oct 13 23:11:00 1992
  107. ***************
  108. *** 1327,1333 ****
  109. --- 1327,1363 ----
  110.       if (ignore_grabs == True &&
  111.           (stuff->reqType == X_GrabServer || stuff->reqType == X_UngrabServer))
  112.       {    /* doesn't want Grab's! Note: this is a "last configured" setting */
  113. + #ifndef NO_NEW_XTRAP
  114. +     int status;
  115. +     if (stuff->reqType == X_GrabServer)
  116. +     {
  117. +         ClientList *pclient;
  118. +         /* first call grab server procedure */
  119. +         status = (*XETrapProcVector[stuff->reqType])(client);
  120. +         /* then add XTrap controlling clients */
  121. +         for (pclient = &io_clients; pclient; pclient = pclient->next)
  122. +         if (pclient->client)
  123. +             AlsoListenToClient(pclient->client);
  124. +     }
  125. +     else
  126. +     {
  127. +         ClientList *pclient;
  128. +         /* first drop XTrap controlling clients */
  129. +         for (pclient = &io_clients; pclient; pclient = pclient->next)
  130. +         if (pclient->client)
  131. +             AlsoUnListenToClient(pclient->client);
  132. +         /* then call ungrab server procedure */
  133. +         status = (*XETrapProcVector[stuff->reqType])(client);
  134. +     }
  135. +     return status;
  136. + #else /* NO_NEW_XTRAP */
  137.           return(Success);
  138. + #endif /* NO_NEW_XTRAP */
  139.       }
  140.       else
  141.       {
  142.